package com.example.mydemo.util;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicInteger;
public class ThreadPoolUtil {
    // 根据需求调整线程数（建议不超过CPU核心数的2倍）
    private static final int THREAD_POOL_SIZE = Runtime.getRuntime().availableProcessors() * 2;
    private static final ExecutorService FIXED_THREAD_POOL = Executors.newFixedThreadPool(THREAD_POOL_SIZE);

    // 原子整数统计总插入数量（线程安全）
    public static final AtomicInteger TOTAL_INSERTED = new AtomicInteger(0);

    public static ExecutorService getFixedThreadPool() {
        return FIXED_THREAD_POOL;
    }

    public static void shutdown() {
        FIXED_THREAD_POOL.shutdown();
    }
}
